<?php
class CommentsForm extends BaseProductCommentForm
{
	public function configure(){

	  sfProjectConfiguration::getActive()->loadHelpers(array('I18N'));

	  $this->useFields(array( 'product_id', 'name', 'message', 'ip', 'host', 'user_id', 'email' ));
	  
      $this->widgetSchema['captcha']= new sfWidgetFormInput(array(), array('title'=> __('enter code') ));
	  $this->widgetSchema['name']= new sfWidgetFormInput(array(), array('title'=> __('name') ));
      $this->widgetSchema['message']= new sfWidgetFormTextarea (array(), array('title' => __('comment')));
	  $this->widgetSchema['email']= new sfWidgetFormInput (array(), array('title' => __('email')));
      $this->widgetSchema['ip']= new sfWidgetFormInputHidden();
      $this->widgetSchema['host']= new sfWidgetFormInputHidden();
      $this->widgetSchema['product_id']= new sfWidgetFormInputHidden();
	  $this->widgetSchema['rating']= new sfWidgetFormInput();

	  $this->validatorSchema['email'] =  new sfValidatorEmail(array('required' => true), array('invalid' => __('wrong email'),'required' => __('email is required') ));
	  $this->validatorSchema['message'] =  new sfValidatorString(array('required' => true), array('required' => __('message is required :)') ));
      $this->validatorSchema['captcha'] =  new sfCaptchaGDValidator(array('length' => 4), array('length' => 'wrong captcha', 'invalid' => 'wrong'));
	  $this->validatorSchema['rating'] =  new sfValidatorInteger(array('required' => false, 'max' => 5, 'min' => 0 ), array());

	  $this->setDefault('message', __('comment'));
	  $this->setDefault('name', __('name'));
	  $this->setDefault('captcha', __('enter code'));
	  $this->setDefault('email', __('email'));

	}

} 